package com.ruoyi.framework.config;

import com.qiniu.common.Zone;
import com.qiniu.storage.Region;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 七牛云配置
 *
 * @author huzhimin
 */
@Component
@ConfigurationProperties(prefix = "qiniu")
public class QiNiuConfig {
    /**
     * AccessKey
     */
    private String accessKey;
    /**
     * SecretKey
     */
    private String secretKey;
    /**
     * 存储区域
     */
    private Region region;

    /**
     * 存储空间
     */
    private String bucket;
    /**
     * 访问地址
     */
    private String httpUrl;

    public String getAccessKey() {
        return accessKey;
    }

    public void setAccessKey(String accessKey) {
        this.accessKey = accessKey;
    }

    public String getSecretKey() {
        return secretKey;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    public String getBucket() {
        return bucket;
    }

    public void setBucket(String bucket) {
        this.bucket = bucket;
    }

    public String getHttpUrl() {
        return httpUrl;
    }

    public void setHttpUrl(String httpUrl) {
        this.httpUrl = httpUrl;
    }

    public Region getRegion() {
        return region;
    }

    public void setRegion(String region) {
        switch (region) {
            case "z0":
                this.region = Region.region0();
                break;
            case "z1":
                this.region = Region.region1();
                break;
            case "z2":
                this.region = Region.region2();
                break;
            case "na0":
                this.region = Region.regionNa0();
                break;
            case "as0":
                this.region = Region.regionAs0();
                break;
            default:
                this.region = Region.region0();
                break;
        }
    }

}
